
********************************************************************************
********************************************************************************

							* SCHOOL SURVEY *

********************************************************************************
********************************************************************************

use "$Endline_dtRaw/school/Questionrio 4 - Escolas.dta", clear

label drop _all

********************************************************************************

// Identification cleaning, apply to all rosters!

drop if inlist(interview__key,"69-28-11-74","12-88-13-89","67-33-56-05")

********************************************************************************

replace school_id = 96 if interview__key == "35-39-65-05"

sort school_id

********************************************************************************


* Survey solutions variables

order interview__key interview__id sssys_irnd has__errors

drop interview__status

label variable interview__id "Unique 32-character long identifier"
label variable interview__key "Interview key (XX-XX-XX-XX format)"
label variable sssys_irnd "Random number range 0..1 associated with interview"
label variable has__errors "Errors count in the interview"

rename interview__id 	ss_id
rename interview__key 	ss_key
rename sssys_irnd 		ss_random
rename has__errors 		ss_errors


drop municipality

drop consensus

// add municipality and treatment variable to data set

gen municipality = .

replace municipality = 1 if inlist(school_id,1,2,3,4,5,6,7,8,9,10,12,13,	///
	14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,32,33,34,35,37,		///
	40,45,61,86,110)

replace municipality = 2 if inlist(school_id,23,43,44,46,47,48,49,50,51,	///
	52,53,54,55,56,57,58,59,60,62,63,64,65,66,67,68,69,70,71,72,73,75,76,	///
	77,78,79,80,81)

replace municipality = 3 if inlist(school_id,11,36,38,39,41,42,74,82,83,84,	///
	85,87,88,89,90,91,92,93,94,95,96,97,98,99,101,102,103,104,105)

replace municipality = 4 if inlist(school_id,118,119,120,121,122,123,124,125)
replace municipality = 5 if inlist(school_id,100,112,113,114,115,116,117)
replace municipality = 6 if inlist(school_id,109,111)
replace municipality = 7 if inlist(school_id,106,107)
replace municipality = 8 if inlist(school_id,126)
replace municipality = 9 if inlist(school_id,108)

gen treatment = .

replace treatment = 0 if inlist(school_id,3,4,7,10,16,18,20,23,26,29,33, ///
	39,42,53,55,62,63,64,65,78,81,84,87,88,89,92,98,108,109,116,117,121)

replace treatment = 1 if inlist(school_id,15,19,22,27,32,36,37,40,49,51, ///
	56,57,58,61,66,68,72,76,79,82,83,86,91,95,100,102,103,106,110,114,125,126)

replace treatment = 2 if inlist(school_id,1,5,6,11,12,14,21,24,25,31,41, ///
	48,50,52,59,70,73,77,80,90,93,94,101,105,107,111,112,113,119,120,124)

replace treatment = 3 if inlist(school_id,2,8,9,13,17,28,30,34,35,38,43, ///
	44,45,46,47,54,60,67,69,71,74,75,85,96,97,99,104,115,118,122,123)


********************************************************************************

order 	school_id treatment school_name municipality supervisor			///
		interviewer date_time_start date_time_end, after(ss_errors)

********************************************************************************

// labelssss

#delimit ;
;
label define treatment
0	"Control group"
1	"Door-to-door"
2	"Meetings"
3	"Both treatments"
;
label define municipality
1	"Sumbe"
2	"Porto Amboim"
3	"Gabela"
4	"Conda"
5	"Ebo"
6	"Quilenda"
7	"Seles"
8	"Cassongue"
9	"Quibala"
;
label define enum
1	"Antonio Lopes Miguel Rocha"
2	"Augusta Júlio Miranda"
3	"César Zau Joaquim Morais Mendes"
4	"Edesdeth Abrantes Fonseca"
5	"Fernando Portugal Leonardo"
6	"Filipe Quissana Cariengue"
7	"Herlander Mauro Lemos Lima"
8	"Manuel Aguinaldo Barroso Moreira Francisco"
9	"Albertina de Oliveira Armando"
10	"Augusto Viana Kupinga"
11	"Beatriz Laurinda Teixeira da Costa"
12	"Carlos da Fonseca Ricardo "
13	"Carolina Germano da Silva"
14	"Felizarda Luis Avelino"
15	"Hermínia Caetano Kalolo"
16	"Ilídio Duarte Reis Cardoso"
17	"Isabel Marcolino Lisboa"
18	"João Monteiro Bimbe"
19	"José Alberto Nungulo Kamucunja"
20	"Manuel Pinheiro Inacio Ernesto"
21	"Marimilia Francisco Fernando"
22	"José Bambi Kandjeke"
23	"Samora Paulo José Ganga"
24	"Victória Maneco Tavares"
25	"Adelaide Fernando Miguens"
26	"Adelaide Marcelina da Cruz Zeferino"
27	"Adilson Fragoso Pascoal Inácio Filipe"
28	"Amaro Alberto Chipa"
29	"Ana Paula Silvestre Ventura"
30	"Antonio Calei Pedro da Silva"
31	"António Manuel da Silva"
32	"Bernardo Miguêns Gimbo"
33	"Bernardo Sungo Manuel Zau"
34	"Bráulio Eanes Gabriel Alberto"
35	"Bruno José Fernando Viegas"
36	"Carvalinho António Correia"
37	"Cirineu Jr. Jorge"
38	"Domingos Guimarães Sumano"
39	"Elvino António Sobral Salomão"
40	"Etelvina Albertina Francisco Teixeira"
41	"Helder Silvestre Lino Tomé Pinto"
42	"Joana Pinto Soma"
43	"Jonas Frederico Albino Rangel"
44	"José Catraio António"
45	"José Luciano Januário"
46	"José Maria Sumano Delgado"
47	"José Pinto Fançony"
48	"Magalhães Salissinga Gomes"
49	"Maria de Fátima Paulo Feliciano"
50	"Mariza Fernando Manuel Vales"
51	"Monteiro Bastos"
52	"Nilton Januário Valentim"
53	"Sara Claúdio Vidro Aguiar Maneco"
54	"Telma da Conceição Mweleyavo António"
55	"Teresa Aguiar da Costa"
56	"Teresa Kizua Kassucada"
57	"Bruno Avelino Segunda"
58	"Inocêncio Mário Cupenala"
59	"Sabino Jorge Bira"
;
label define resp_position
1 `"Director"'
2 `"Deputy director"'
3 `"Acting director"'
;
label define dummy
0	"No"
1 	"Yes"
;
label define community_type
1 `"Urbana"'
2 `"Rural"'
;
#delimit cr

********************************************************************************

label values supervisor interviewer enum
label values resp_position resp_position
label values municipality municipality
label values treatment treatment

label variable date_time_start `"Date and time start interview"'
label variable date_time_end `"Date and time end interview"'
label variable school_id `"ID number school"'
label variable municipality "Municipality"
label variable treatment "Treatment group"
label variable school_name `"Name school"'
label variable supervisor `"Supervisor"'
label variable interviewer `"Interviewer"'
label variable school_tel `"Phone number school"'
label variable resp_name `"Name main respondent"'
label variable resp_position `"Position of main respondent at the school"'
label variable resp_tel `"Phone number main respondent"'


label values community_type community_type
label variable community_type `"Type of community"'
label variable community_size `"Number of people living in community or neighbourhood"'
label variable school_distance `"Distance school to center closest municipality."'

drop muni

save "$Endline_dtRaw/_intermediate files/school.dta", replace

********************************************************************************

* add other respondents

use "$Endline_dtRaw/school/id_roster.dta", clear

label drop _all

drop if inlist(interview__key,"69-28-11-74","12-88-13-89","67-33-56-05")

rename interview__id 	ss_id
rename interview__key 	ss_key
rename id_roster__id roster_id_Sintro

rename resp_allnames resp_name_other_
rename resp_listposition resp_position_other_
drop resp_listposition_other

drop ss_id

#delimit ;
;
label define resp_position_other_
1 `"Director"'
2 `"Deputy director"'
3 `"Teacher"'
4 `"Member of school secretary"'
;
#delimit cr

label values resp_position_other_ resp_position_other_

reshape wide resp_name_other_ resp_position_other_, i(ss_key) j(roster_id_Sintro)

label variable resp_name_other_1 `"Name other respondent"'
label variable resp_name_other_2 `"Name other respondent"'
label variable resp_name_other_3 `"Name other respondent"'
label variable resp_position_other_1 `"Position of other respondent"'
label variable resp_position_other_2 `"Position of other respondent"'
label variable resp_position_other_3 `"Position of other respondent"'

save "$Endline_dtRaw/_intermediate files/school_ids.dta", replace

********************************************************************************

use "$Endline_dtRaw/_intermediate files/school.dta", clear

merge 1:1 ss_key using "$Endline_dtRaw/_intermediate files/school_ids.dta"

drop _merge

order resp_name_other_1 resp_position_other_1 resp_name_other_2 	///
		resp_position_other_2 resp_name_other_3 					///
		resp_position_other_3, after(resp_tel)

replace resp_extra = resp_extra + 1
rename resp_extra resp_total
lab var resp_total "Total number of respondents"

foreach var in school_tel resp_tel community_size school_distance{
replace `var' = . if `var'==999
}

********************************************************************************

// labelssss

#delimit ;
;
label define dummy
0	"No"
1 	"Yes"
;
label define S01_01_02
1 `"January"'
2 `"February"'
3 `"March"'
4 `"April"'
5 `"May"'
6 `"June"'
7 `"July"'
8 `"August"'
9 `"September"'
10 `"October"'
11 `"November"'
12 `"December"'
;
label define S01_02
1 `"FAS"'
2 `"National government"'
3 `"Provincial/municipal government"'
4 `"NGO"'
5 `"Local (religious) group"'
6 `"Community based (private) organisation or individual"'
;
label define S01_03
1 `"FAS"'
2 `"National government"'
3 `"Provincial/municipal government"'
4 `"NGO"'
5 `"Local (religious) group"'
6 `"School fees and parent contributions"'
;
#delimit cr

********************************************************************************

* Section 1

replace S01_01_01 = . if S01_01_01==999
replace S01_01_02 = . if S01_01_02==999

label variable S01_01_01 `"Founding year school"'
label variable S01_01_02 `"Founding month school"'
label variable S01_02 `"Founding institution school"'
label variable S01_03 `"Institution paying salaries of staff"'

label values S01_01_02 S01_01_02
label values S01_02 S01_02

replace S01_02 = . if inlist(S01_02,7,999)

replace S01_02 = 6 if S01_02_other=="Paenal, Herema"
replace S01_02 = 6 if S01_02_other=="Senhor João Manuel Gonçálveis Lourenço"
replace S01_02 = 6 if S01_02_other=="Total"
replace S01_02 = 6 if S01_02_other=="Sonangol Logistica"
replace S01_02 = 6 if S01_02_other=="Amigo e Natural da Zunzua"

replace S01_02 = 1 if S01_02_other=="Fesa e Fas"
replace S01_02 = 2 if S01_02_other=="As  primeiras salas foram feitas pelo Estado, as segundas pelos encarregados e as outras pelo FAS"

drop S01_02_other

replace S01_03 = 2 if S01_03==7
label values S01_03 S01_03

drop S01_03_other

foreach var in S01_04__1 S01_04__2 S01_04__3 S01_04__4 S01_04__5 ///
				S01_04__6 S01_04__7{
	replace `var' = . if `var'==-999999999
	}

replace S01_04__7 = 0 if S01_04_other=="Comparticipação dos Encarregados"
replace S01_04__6 = 1 if S01_04_other=="Comparticipação dos Encarregados"

label variable S01_04__1 `"School budget funded by FAS"'
label variable S01_04__2 `"School budget funded by national government"'
label variable S01_04__3 `"School budget funded by provincial/municipal government"'
label variable S01_04__4 `"School budget funded by NGO"'
label variable S01_04__5 `"School budget funded by local (religious) group"'
label variable S01_04__6 `"School budget funded by school fees and parent contributions"'

rename S01_04__7 S01_04__0
label variable S01_04__0 `"School does not have any budget"'

order S01_04__0, before(S01_04__1)

lab val S01_04__0 S01_04__1 S01_04__2 S01_04__3 S01_04__4 S01_04__5 ///
			S01_04__6 dummy

drop S01_04_sumperc


foreach var in S01_04_01 S01_04_02 S01_04_03 S01_04_04 S01_04_05 ///
				S01_04_06 S01_04_07 {
	replace `var' = . if `var'==999
	}

label variable S01_04__1 `"School budget funded by FAS"'
label variable S01_04__2 `"School budget funded by national government"'
label variable S01_04__3 `"School budget funded by provincial/municipal government"'
label variable S01_04__4 `"School budget funded by NGO"'
label variable S01_04__5 `"School budget funded by local (religious) group"'
label variable S01_04__6 `"School budget funded by school fees and parent contributions"'

replace S01_04_06 = S01_04_07 if S01_04_other=="Comparticipação dos Encarregados"

drop S01_04_other S01_04_07

label variable S01_04_01 `"Percentage school budget funded by FAS"'
label variable S01_04_02 `"Percentage school budget funded by national government"'
label variable S01_04_03 `"Percentage school budget funded by provincial/municipal government"'
label variable S01_04_04 `"Percentage school budget funded by NGO"'
label variable S01_04_05 `"Percentage school budget funded by local (religious) group"'
label variable S01_04_06 `"Percentage school budget funded by school fees and parent contributions"'

label variable S01_05__0 `"School has pre-school classes"'
label variable S01_05__1 `"School has 1st grade classes"'
label variable S01_05__2 `"School has 2nd grade classes"'
label variable S01_05__3 `"School has 3rd grade classes"'
label variable S01_05__4 `"School has 4th grade classes"'
label variable S01_05__5 `"School has 5th grade classes"'
label variable S01_05__6 `"School has 6th grade classes"'
label variable S01_05__7 `"School has 7th grade classes"'
label variable S01_05__8 `"School has 8th grade classes"'
label variable S01_05__9 `"School has 9th grade classes"'

lab val S01_05__0 S01_05__1 S01_05__2 S01_05__3 S01_05__4 S01_05__5 ///
		S01_05__6 S01_05__7 S01_05__8 S01_05__9 S01_06 S01_07__11 	///
		S01_07__12 S01_07__13 S01_08 dummy

label variable S01_06 `"School has modules"'
label variable S01_07__11 `"School has module 1 (Grades 1 and 2)"'
label variable S01_07__12 `"School has module 2 (Grades 3 and 4)"'
label variable S01_07__13 `"School has module 3 (Grades 5 and 6)"'
label variable S01_08 `"School has classes with more than one grade"'

gen S01_09 = ""
replace S01_09 = "1, 2, 3, 4, 5" if S01_09__1 == "2"
replace S01_09 = "2, 8" if S01_09__0 == "28"
replace S01_09 = "1, 6" if S01_09__0 == "1 , 6"
replace S01_09 = "1, 6" if S01_09__0 == "1 e 6"
replace S01_09 = "1, 3, 4, 6" if S01_09__0 == "1,3 ,4e6"
replace S01_09 = "2, 4" if S01_09__0 == "2  a 4"
replace S01_09 = "2, 3" if S01_09__0 == "2 e 3"
replace S01_09 = "2, 6" if S01_09__0 == "2 e 6"
replace S01_09 = "3, 6" if S01_09__0 == "3 e 6"
replace S01_09 = "4, 5" if S01_09__0 == "4 e 5"
replace S01_09 = "1, 2, 3, 4" if S01_09__0 == "Primeira e segunda, terceira e quarta classe"

order S01_09, after(S01_08)

lab var S01_09 "Classses with more than one grade specified"

drop S01_09__0 S01_09__1 S01_09__2 S01_09__3 S01_09__4

replace S01_10 = . if S01_10==999
replace S01_12 = . if S01_12==999

label variable S01_10 `"Number of other schools close by (5km)"'
label variable S01_11 `"Public transportation close by"'
label variable S01_12 `"Number of school weeks per year"'
label variable S01_13 `"Number of class hours in a day"'
label variable S01_14 `"Classes outside"'

lab val S01_11 S01_14 dummy

********************************************************************************

* Section 2

lab val S02_01 dummy

drop S02_02__4 S02_02__5 S02_02__6 S02_02__7 S02_02__8 S02_02__9

foreach var in S02_02__0 S02_02__1 S02_02__2 S02_02__3 {
replace `var' = "" if `var' == "##N/A##"
}

save "$Endline_dtRaw/_intermediate files/school.dta", replace

********************************************************************************

use "$Endline_dtRaw/school/S02_roster.dta", clear

label drop _all


drop if inlist(interview__key,"69-28-11-74","12-88-13-89","67-33-56-05")

drop interview__id
rename interview__key 	ss_key
rename S02_roster__id roster_id_S02

/// labels

#delimit ;
;
label define dummy
0	"No"
1 	"Yes"
;
label define S02_03
1 `"Construction"'
2 `"Improvement"'
;
label define S02_06
1 `"FAS"'
2 `"National government"'
3 `"Provincial/municipal government"'
4 `"NGO"'
5 `"Local (religious) group"'
6 `"Parents"'
7 `"Community or private contribution"'
;
#delimit cr

// unrelated investment:
drop if S02_03_other=="Agricultura"
drop if S02_04_other=="Recursos Humanos"



lab var S02_02 "Project description"

lab val S02_03 S02_03

label variable S02_03 `"Type of project"'

drop S02_03_other

label variable S02_04__1 `"Project regarding classrooms"'
label variable S02_04__2 `"Project regarding director/teacher/staff rooms"'
label variable S02_04__3 `"Project regarding bathrooms"'
label variable S02_04__4 `"Project regarding outdoor spaces"'
label variable S02_04__5 `"Project regarding dorms"'
label variable S02_04__6 `"Project regarding teacher homes"'
label variable S02_04__7 `"Project regarding library"'
label variable S02_04__8 `"Project regarding storage"'
label variable S02_04__9 `"Project regarding other space"'
label variable S02_04_other `"[OTHER] Installation involved with project"'

lab val S02_04__1 S02_04__2 S02_04__3 S02_04__4 S02_04__5 S02_04__6 ///
		S02_04__7 S02_04__8 dummy

replace S02_04__1 = 1 if S02_04_other=="Outras Instalações"
replace S02_04__4 = 1 if inlist(S02_04_other,"Em volta à escola","Vedação","Vedação da escola")

drop S02_04__9 S02_04_other

replace S02_05 = . if S02_05==999
replace S02_06 = . if S02_06==999

label variable S02_05 `"School received suport for this project"'
label variable S02_06 `"Main source of suport for project"'
label variable S02_07 `"Parents contributed for project"'
label variable S02_08 `"Contributed days for project by parents"'
label variable S02_09 `"Value of materials contributed for project by parents"'
label variable S02_10 `"Money contributed for project by parents."'

label values S02_06 S02_06
label values S02_05 S02_07 dummy

replace S02_06 = 6 if S02_06_other=="não houve financiamento foi apenas esforço dos encarregado"
replace S02_06 = 7 if S02_06_other=="doação"
replace S02_06 = 7 if S02_06_other=="Investidor Privado por meio do Governo"

drop S02_06_other

foreach var in S02_08 S02_09 S02_10{
replace `var' = . if `var'==999
}


replace S02_07 = 1 if S02_06==6


foreach var in S02_02 S02_03 S02_04__1 S02_04__2 S02_04__3 S02_04__4 ///
		S02_04__5 S02_04__6 S02_04__7 S02_04__8 S02_05 S02_06 S02_07 ///
		S02_08 S02_09 S02_10{
rename `var' `var'_
}

reshape wide S02_02_ S02_03_ S02_04__1_ S02_04__2_ S02_04__3_ S02_04__4_ ///
		S02_04__5_ S02_04__6_ S02_04__7_ S02_04__8_ S02_05_ S02_06_  	///
		S02_07_ S02_08_ S02_09_ S02_10_, i(ss_key) j(roster_id_S02)

forval x = 1/3{
lab var S02_02_`x' "(`x') Project description"
label variable S02_03_`x' `"(`x') Type of project"'
label variable S02_04__1_`x' `"(`x') Project regarding classrooms"'
label variable S02_04__2_`x' `"(`x') Project regarding director/teacher/staff rooms"'
label variable S02_04__3_`x' `"(`x') Project regarding bathrooms"'
label variable S02_04__4_`x' `"(`x') Project regarding outdoor spaces"'
label variable S02_04__5_`x' `"(`x') Project regarding dorms"'
label variable S02_04__6_`x' `"(`x') Project regarding teacher homes"'
label variable S02_04__7_`x' `"(`x') Project regarding library"'
label variable S02_04__8_`x' `"(`x') Project regarding storage"'
label variable S02_05_`x' `"(`x') School received suport for this project"'
label variable S02_06_`x' `"(`x') Main source of suport for project"'
label variable S02_07_`x' `"(`x') Parents contributed for project"'
label variable S02_08_`x' `"(`x') Contributed days for project by parents"'
label variable S02_09_`x' `"(`x') Value of materials contributed for project by parents"'
label variable S02_10_`x' `"(`x') Money contributed for project by parents."'
}

save "$Endline_dtRaw/_intermediate files/school_S02.dta", replace

********************************************************************************

use "$Endline_dtRaw/_intermediate files/school.dta", clear

merge 1:1 ss_key using "$Endline_dtRaw/_intermediate files/school_S02.dta"

order 	S02_02_1 S02_03_1 S02_04__1_1 S02_04__2_1 S02_04__3_1 S02_04__4_1 	///
		S02_04__5_1 S02_04__6_1 S02_04__7_1 S02_04__8_1 S02_05_1 S02_06_1 	///
		S02_07_1 S02_08_1 S02_09_1 S02_10_1 S02_02_2 S02_03_2 S02_04__1_2 	///
		S02_04__2_2 S02_04__3_2 S02_04__4_2 S02_04__5_2 S02_04__6_2 		///
		S02_04__7_2 S02_04__8_2 S02_05_2 S02_06_2 S02_07_2 S02_08_2 		///
		S02_09_2 S02_10_2 S02_02_3 S02_03_3 S02_04__1_3 S02_04__2_3 		///
		S02_04__3_3 S02_04__4_3 S02_04__5_3 S02_04__6_3 S02_04__7_3 		///
		S02_04__8_3 S02_05_3 S02_06_3 S02_07_3 S02_08_3 S02_09_3 			///
		S02_10_3, after(S02_02__3)

drop S02_02__0 S02_02__1 S02_02__2 S02_02__3 _merge

lab var S02_01 "School did (re)construction during last two years"

********************************************************************************

* Section 3

// labelssss

#delimit ;
;
label define S03_03
1 `"FAS"'
2 `"National government"'
3 `"Provincial/municipal government"'
4 `"NGO"'
5 `"Local (religious) group"'
6 `"Parents"'
7 `"Community or private contribution"'
;
#delimit cr


lab val S03_01__1 S03_01__2 S03_01__3 S03_01__4 S03_01__5 S03_01__6 	///
		S03_01__7 S03_01__8 S03_01__9 dummy



foreach var in 	S03_01__1 S03_01__2 S03_01__3 S03_01__4 			///
				S03_01__5 S03_01__6 S03_01__7 S03_01__8	{
	replace S03_01__9 = 0 if `var'==1
	}

label variable S03_01__1 `"New school books"'
label variable S03_01__2 `"New exercise books"'
label variable S03_01__3 `"New administration books"'
label variable S03_01__4 `"New desks"'
label variable S03_01__5 `"New chairs"'
label variable S03_01__6 `"New blackboards"'
label variable S03_01__7 `"New boxes with chalk"'
label variable S03_01__8 `"New educational posters"'
label variable S03_01__9 `"No new resourses"'


label variable S03_02_01 `"Received (partial) contribution for school books"'
label variable S03_02_02 `"Received (partial) contribution for exercise books"'
label variable S03_02_03 `"Received (partial) contribution for administration books"'
label variable S03_02_04 `"Received (partial) contribution for desks"'
label variable S03_02_05 `"Received (partial) contribution for chairs"'
label variable S03_02_06 `"Received (partial) contribution for blackboards"'
label variable S03_02_07 `"Received (partial) contribution for boxes with chalk"'
label variable S03_02_08 `"Received (partial) contribution for educational posters"'

lab val S03_02_01 S03_02_02 S03_02_03 S03_02_04 S03_02_05 			///
		S03_02_06 S03_02_07 S03_02_08 dummy


label variable S03_03_01 `"Main donor for investment in school books"'
label variable S03_03_02 `"Main donor for investment in exercise books"'
label variable S03_03_03 `"Main donor for investment in administration books"'
label variable S03_03_04 `"Main donor for investment in desks"'
label variable S03_03_05 `"Main donor for investment in chairs"'
label variable S03_03_06 `"Main donor for investment in blackboards"'
label variable S03_03_07 `"Main donor for investment in boxes with chalk"'
label variable S03_03_08 `"Main donor for investment in educational posters"'

lab val S03_03_01 S03_03_02 S03_03_03 S03_03_04 S03_03_05 			///
		S03_03_06 S03_03_07 S03_03_08 S03_03

recode S03_03_01 S03_03_02 S03_03_03 S03_03_04 S03_03_05 			///
		S03_03_06 S03_03_07 S03_03_08 (8=3)

replace S03_03_04 = 2 if S03_03_04_other=="PAT"
replace S03_03_07 = 7 if S03_03_07_other=="Director Carlos de Brito Pacheco"

drop 	S03_03_01_other S03_03_02_other S03_03_03_other S03_03_04_other ///
		S03_03_05_other S03_03_06_other S03_03_07_other S03_03_08_other


lab val 	S03_04_01 S03_04_02 S03_04_03 S03_04_04 S03_04_05 			///
			S03_04_06 S03_04_07 S03_04_08 dummy

label variable S03_04_01 `"Parent contributions for investment in school books"'
label variable S03_04_02 `"Parent contributions for investment in exercise books"'
label variable S03_04_03 `"Parent contributions for investment in administration books"'
label variable S03_04_04 `"Parent contributions for investment in desks"'
label variable S03_04_05 `"Parent contributions for investment in chairs"'
label variable S03_04_06 `"Parent contributions for investment in blackboards"'
label variable S03_04_07 `"Parent contributions for investment in boxes with chalk"'
label variable S03_04_08 `"Parent contributions for investment in educational posters"'

label variable S03_05_01 `"Value of materials contributed by parents for school books"'
label variable S03_06_01 `"Money contributed by parents for school books"'
label variable S03_05_02 `"Value of materials contributed by parents for exercise books"'
label variable S03_06_02 `"Money contributed by parents for exercise books"'
label variable S03_05_03 `"Value of materials contributed by parents for administration books"'
label variable S03_06_03 `"Money contributed by parents for administration books"'
label variable S03_05_04 `"Value of materials contributed by parents for desks"'
label variable S03_06_04 `"Money contributed by parents for desks"'
label variable S03_05_05 `"Value of materials contributed by parents for chairs"'
label variable S03_06_05 `"Money contributed by parents for chairs"'
label variable S03_05_06 `"Value of materials contributed by parents for blackboards"'
label variable S03_06_06 `"Money contributed by parents for blackboards"'
label variable S03_05_07 `"Value of materials contributed by parents for boxes with chalk"'
label variable S03_06_07 `"Money contributed by parents for boxes with chalk"'
label variable S03_05_08 `"Value of materials contributed by parents for educational posters"'
label variable S03_06_08 `"Money contributed by parents for educational posters"'

foreach var in 	S03_05_01 S03_05_02 S03_05_03 S03_05_04 S03_05_05 ///
				S03_05_06 S03_05_07 S03_05_08 S03_06_01 S03_06_02 ///
				S03_06_03 S03_06_04 S03_06_05 S03_06_06 S03_06_07 ///
				S03_06_08 {
	replace `var' = . if `var' == 999
}

save "$Endline_dtRaw/_intermediate files/school.dta", replace

********************************************************************************

* Section 4

* add roster R04

use "$Endline_dtRaw/school/S04_roster.dta", clear

label drop _all

drop if inlist(interview__key,"69-28-11-74","12-88-13-89","67-33-56-05")

drop interview__id
rename interview__key 	ss_key
rename S04_roster__id roster_id_S04


/// labels

#delimit ;
;
label define S04_03
1 `"0 - 500 meters"'
2 `"501 meters - 1 km"'
3 `"1 - 5 km"'
4 `"6 - 10 km"'
5 `"10 - 20 km"'
6 `"More than 20 km"'
;
# delimit cr

replace S04_02 = . if S04_02==999

lab val S04_03 S04_03

rename (S04_01 S04_02 S04_03) (S04_01_ S04_02_ S04_03_)
reshape wide S04_01_ S04_02_ S04_03_, i(ss_key) j(roster_id_S04)

forval x=1/5 {
	lab var S04_01_`x' "(`x') Name neighborhood"
	lab var S04_02_`x' "(`x') Percentage of students from this neighborhood"
	lab var S04_03_`x' "(`x') Distance neighborhood to school"
}


save "$Endline_dtRaw/_intermediate files/school_S04.dta", replace

********************************************************************************

use "$Endline_dtRaw/_intermediate files/school.dta", clear

merge 1:1 ss_key using "$Endline_dtRaw/_intermediate files/school_S04.dta"

order 	S04_01_1 S04_02_1 S04_03_1 S04_01_2 S04_02_2 S04_03_2 S04_01_3 ///
		S04_02_3 S04_03_3 S04_01_4 S04_02_4 S04_03_4 S04_01_5 S04_02_5 ///
		S04_03_5, after(S03_06_08)

drop S04_01__0 S04_01__1 S04_01__2 S04_01__3 S04_01__4 _merge


********************************************************************************


label variable S04_04__0 `"There are no requirements for admitting students (besides age)"'
label variable S04_04__1 `"Students are admitted based on location residence"'
label variable S04_04__2 `"Students are admitted on a first come first serve basis""'
label variable S04_04__3 `"Students are admitted based on personal relations"'
label variable S04_04__4 `"Students are admitted based on parent contributions to school"'
label variable S04_04__5 `"There is a preference for students with already a brother or sister at the school"'

replace S04_04__0 = 1 if S04_04__6==1
replace S04_04__0 = 0 if S04_04_other=="Alunos com dificiencias"
replace S04_04__0 = 0 if S04_04_other=="Entrevistas"

drop S04_04__6 S04_04__999
gen S04_04__6 = ""
replace S04_04__6 = "School serves particular target group (disability)" ///
	if S04_04_other=="Alunos com dificiencias"
replace S04_04__6 = "Interviews" if S04_04_other=="Entrevistas"
order S04_04__6, after(S04_04__5)
label variable S04_04__6 `"Other way of admitting students (string)"'
drop S04_04_other
lab val S04_04__0 S04_04__1 S04_04__2 S04_04__3 S04_04__4 S04_04__5 dummy

********************************************************************************

* Section 5

label variable S05_01 `"Results of 2017 available"'
label variable S05_04 `"Results of 2016 available"'
label variable S05_07 `"Results of 2015 available"'

lab val S05_01 S05_04 S05_07 dummy

label variable S05_02_01 `"Number of students that did the final exam in 2017"'
label variable S05_02_02 `"Number of girls that did the final exam in 2017"'
label variable S05_03_01 `"Number of students that past the final exam in 2017"'
label variable S05_03_02 `"Number of girls that past the final exam in 2017"'

label variable S05_05_01 `"Number of students that did the final exam in 2016"'
label variable S05_05_02 `"Number of girls that did the final exam in 2016"'
label variable S05_06_01 `"Number of students that past the final exam in 2016"'
label variable S05_06_02 `"Number of girls that past the final exam in 2016"'

label variable S05_08_01 `"Number of students that did the final exam in 2015"'
label variable S05_08_02 `"Number of girls that did the final exam in 2015"'
label variable S05_09_01 `"Number of students that past the final exam in 2015"'
label variable S05_09_02 `"Number of girls that past the final exam in 2015"'

foreach var in 	S05_02_01 S05_02_02 S05_03_01 S05_03_02 S05_05_01 	///
				S05_05_02 S05_06_01 S05_06_02 S05_08_01 S05_08_02 	///
				S05_09_01 S05_09_02{
	replace `var' = . if `var'==999
	}

********************************************************************************

* Section 6

// labelssss

#delimit ;
;
label define S06_03
0 `"Never"'
1 `"Monthly"'
2 `"Every trimester"'
3 `"Twice per year"'
4 `"Once per year"'
;
label define S06_04
1 `"Yes, up-to-date"'
2 `"Yes, but not up-to-date"'
0 `"No"'
;
label define S06_06
1 `"Director office"'
2 `"Secretary office"'
3 `"Hall/entrance"'
4 `"Classroom"'
5 `"Teachers room"'
6 `"Outside of the school"'
7 `"Non-school building close-by"'
;
#delimit cr

label variable S06_01 `"School has yearly school plan"'

lab val S06_01 dummy

label variable S06_02__1 `"Director is involved with development school plan"'
label variable S06_02__2 `"Deputy director is involved with development school plan"'
label variable S06_02__3 `"School board is involved with development school plan"'
label variable S06_02__4 `"Teachers are involved with development school plan"'
label variable S06_02__5 `"Parent committee is involved with development school plan"'
label variable S06_02__6 `"Provincial board of edu is involved with development school plan"'
label variable S06_02__7 `"Municipal/community representative is involved with development school plan"'
label variable S06_02__8 `"Community is involved with development school plan"'

drop S06_02__9
gen S06_02__9 = 0 if S06_01==1
replace S06_02__9 = 1 if S06_02_other=="Alunos"
replace S06_02__9 = 1 if S06_02_other=="Os alunos"
replace S06_02__3 = 1 if S06_02_other=="Conselho de direção"
replace S06_02__4 = 1 if S06_02_other=="Coordenador de classe"
replace S06_02__4 = 1 if S06_02_other=="cordenador de turno"
replace S06_02__7 = 1 if S06_02_other=="soba"

label variable S06_02__9 `"Students are involved with development school plan"'

order S06_02__9, after(S06_02__8)

drop S06_02_other

label values S06_03 S06_03
label variable S06_03 `"Frequency of reviewing yearly school plan"'

replace S06_03 = 4 if S06_03_other=="caso haja necessidade"
replace S06_03 = 4 if S06_03_other=="quando necessário"
replace S06_03 = 4 if S06_03_other=="sempre que houver necessidades"
replace S06_03 = 1 if S06_03_other=="Duas vezes a cada trimestre"
replace S06_03 = 2 if S06_03_other=="Três vezes por ano"

drop S06_03_other

label values S06_04 S06_04
label variable S06_04 `"School has attendance list professors"'

label variable S06_05_01__1 `"Teachers list available"'
label variable S06_05_01__2 `"Teachers attendance information available"'
label variable S06_05_01__3 `"Yearly school plan available"'
label variable S06_05_01__4 `"Student results available"'
label variable S06_05_01__5 `"Board members list available"'
label variable S06_05_01__6 `"Parent committee list available"'
label variable S06_05_01__7 `"Exam time information available"'
label variable S06_05_01__8 `"Teacher evaluation information available"'

drop S06_05_01__0 S06_05_02__0
lab val 	S06_05_01__1 S06_05_01__2 S06_05_01__3 S06_05_01__4 	///
			S06_05_01__5 S06_05_01__6 S06_05_01__7 S06_05_01__8 dummy

label variable S06_05_02__1 `"Teachers list PUBLICLY available"'
label variable S06_05_02__2 `"Teachers attendance information PUBLICLY available"'
label variable S06_05_02__3 `"Yearly school plan PUBLICLY available"'
label variable S06_05_02__4 `"Student results PUBLICLY available"'
label variable S06_05_02__5 `"Board members list PUBLICLY available"'
label variable S06_05_02__6 `"Parent committee list PUBLICLY available"'
label variable S06_05_02__7 `"Exam time information PUBLICLY available"'
label variable S06_05_02__8 `"Teacher evaluation information PUBLICLY available"'

lab val S06_06_01 S06_06_02 S06_06_03 S06_06_04 S06_06_05 	///
		S06_06_06 S06_06_07 S06_06_08 S06_06

label variable S06_06_01 `"Placement teachers list"'
label variable S06_06_02 `"Placement teachers attendance information"'
label variable S06_06_03 `"Placement yearly school plan"'
label variable S06_06_04 `"Placement student results"'
label variable S06_06_05 `"Placement board members list"'
label variable S06_06_06 `"Placement parent committee list"'
label variable S06_06_07 `"Placement exam time information"'
label variable S06_06_08 `"Placement teacher evaluation information"'

replace S06_06_04 = 3 if S06_06_04==8
replace S06_06_06 = 3 if S06_06_06==8
replace S06_06_07 = 3 if S06_06_07==8

replace S06_06_06 = . if S06_06_06_other=="Publicado aos encarregados verbalmente"
replace S06_05_02__6 = 0 if S06_06_06_other=="Publicado aos encarregados verbalmente"

label values S06_07 S06_08 dummy
label variable S06_07 `"Student registration lists are available"'
label variable S06_08 `"School provides lunches for students"'
label variable S06_09 `"Number of inspection visits last 2 years"'
replace S06_09 = . if S06_09==999

drop 	S06_06_01_other S06_06_02_other S06_06_03_other S06_06_04_other	///
		S06_06_05_other S06_06_06_other S06_06_07_other S06_06_08_other



********************************************************************************

* Section 7

label variable S07_01 `"Number of professors"'

save "$Endline_dtRaw/_intermediate files/school.dta", replace

********************************************************************************

* Add roster

use "$Endline_dtRaw/school/S07_roster.dta", clear

label drop _all

drop if inlist(interview__key,"69-28-11-74","12-88-13-89","67-33-56-05")

drop interview__id
rename interview__key 	ss_key
rename S07_roster__id roster_id_S07

// labelssss

#delimit ;
;
label define dummy
0	"No"
1 	"Yes"
;
label define female
0 `"Male"'
1 `"Female"'
;
label define edu2
0 `"No education"'
1 `"First grade"'
2 `"Primary school 1 (grades 1-4)"'
3 `"Primary school 2 (grades 5-6)"'
4 `"Secondary school 1 (grades 7-8) terceiro nivel"'
5 `"Secondary school 2 (grades 9-12) - ensino medio"'
6 `"Technical and Vocational Education (2-4 years)"'
7 `"University 1st year - Angola"'
8 `"University 1st year - abroad"'
9 `"University - Angola"'
10 `"University - abroad"'
11 `"Pos-graduation - Angola"'
12 `"Pos-graduation - abroad"'
;
#delimit cr

drop ao7 director7 ao7cap

drop if S07_03==-999999999

label variable S07_02 `"Name of teacher"'

label values S07_03 female
label variable S07_03 `"Gender teacher"'

label values S07_04 dummy
label variable S07_04 `"This teacher is also the director"'

label variable S07_05_T `"Questionnaire ID teacher"'
label variable S07_05_D `"Questionnaire ID teacher"'

label variable S07_06 `"Years teaching at this school"'

replace S07_06 = . if S07_06==999

label variable S07_07__0 `"Teacher of pre-school classes"'
label variable S07_07__1 `"Teacher of 1st grade classes"'
label variable S07_07__2 `"Teacher of 2nd grade classes"'
label variable S07_07__3 `"Teacher of 3rd grade classes"'
label variable S07_07__4 `"Teacher of 4th grade classes"'
label variable S07_07__5 `"Teacher of 5th grade classes"'
label variable S07_07__6 `"Teacher of 6th grade classes"'
label variable S07_07__7 `"Teacher of 7th grade classes"'
label variable S07_07__8 `"Teacher of 8th grade classes"'
label variable S07_07__9 `"Teacher of 9th grade classes"'
label variable S07_07__11 `"Teacher of module 1 classes (grades 1 and 2)"'
label variable S07_07__12 `"Teacher of module 2 classes (grades 3 and 4)"'
label variable S07_07__13 `"Teacher of module 3 classes (grades 5 and 6)"'

label variable S07_08__0 `"Last years teacher of pre-school classes"'
label variable S07_08__1 `"Last years teacher of 1st grade classes"'
label variable S07_08__2 `"Last years teacher of 2nd grade classes"'
label variable S07_08__3 `"Last years teacher of 3rd grade classes"'
label variable S07_08__4 `"Last years teacher of 4th grade classes"'
label variable S07_08__5 `"Last years teacher of 5th grade classes"'
label variable S07_08__6 `"Last years teacher of 6th grade classes"'
label variable S07_08__7 `"Last years teacher of 7th grade classes"'
label variable S07_08__8 `"Last years teacher of 8th grade classes"'
label variable S07_08__9 `"Last years teacher of 9th grade classes"'
label variable S07_08__11 `"Last years teacher of module 1 classes (grades 1 and 2)"'
label variable S07_08__12 `"Last years teacher of module 2 classes (grades 3 and 4)"'
label variable S07_08__13 `"Last years teacher of module 3 classes (grades 5 and 6)"'

lab val S07_07__0 S07_07__1 S07_07__2 S07_07__3 S07_07__4 S07_07__5 	///
		S07_07__6 S07_07__7 S07_07__8 S07_07__9 S07_07__11 S07_07__12 	///
		S07_07__13 S07_08__0 S07_08__1 S07_08__2 S07_08__3 S07_08__4 	///
		S07_08__5 S07_08__6 S07_08__7 S07_08__8 S07_08__9 S07_08__11 	///
		S07_08__12 S07_08__13 dummy

foreach var in S07_08__0 S07_08__1 S07_08__2 S07_08__3 S07_08__4 S07_08__5 	///
				S07_08__6 S07_08__7 S07_08__8 S07_08__9 S07_08__11 			///
				S07_08__12 S07_08__13{
	replace `var' = . if `var'==-999999999
	}


label values S07_09 edu2
label variable S07_09 `"Highest level of education enjoyed by teacher"'

label variable S07_10 `"Monthly salary of teacher"'

label variable S07_11 `"Days that teacher was absent last two weeks"'

label variable S07_12 `"Days that teacher was absent in November 2017"'


foreach var in S07_09 S07_10 S07_11 S07_12{
	replace `var' = . if `var' == 999
	}

replace S07_10 = S07_10/1000 if S07_10>1000000

save "$Endline_dtRaw/_intermediate files/school_S07.dta", replace

********************************************************************************
********************* NOTE THAT THERE IS NO MERGE WITH THIS TEACHER ROSTER YET!!
********************************************************************************

use "$Endline_dtRaw/_intermediate files/school.dta", clear

********************************************************************************

* Section 8

label variable S08_01 `"Number of board members"'

save "$Endline_dtRaw/_intermediate files/school.dta", replace

********************************************************************************

*Add roster

use "$Endline_dtRaw/school/S08_roster1.dta", clear

label drop _all

drop if inlist(interview__key,"69-28-11-74","12-88-13-89","67-33-56-05")

drop interview__id
rename interview__key 	ss_key
rename S08_roster1__id roster_id_S08_1


// labelssss

#delimit ;
;
label define dummy
0	"No"
1 	"Yes"
;
label define female
0 `"Male"'
1 `"Female"'
;
label define edu2
0 `"No education"'
1 `"First grade"'
2 `"Primary school 1 (grades 1-4)"'
3 `"Primary school 2 (grades 5-6)"'
4 `"Secondary school 1 (grades 7-8) terceiro nivel"'
5 `"Secondary school 2 (grades 9-12) - ensino medio"'
6 `"Technical and Vocational Education (2-4 years)"'
7 `"University 1st year - Angola"'
8 `"University 1st year - abroad"'
9 `"University - Angola"'
10 `"University - abroad"'
11 `"Pos-graduation - Angola"'
12 `"Pos-graduation - abroad"'
;
label define S08_04
1 `"Director"'
2 `"Deputy director"'
3 `"Teacher"'
4 `"Member of secretary/administration"'
5 `"Representative of the parents committee"'
6 `"Representative of the community"'
7 `"Student representative"'
8 `"Cleaning person"'
;
label define S08_05
1 `"President"'
2 `"Vice-president"'
3 `"Treasurer"'
4 `"Secretary"'
5 `"Member"'
;
label define ocu
1 `"Part-time job in private sector"'
2 `"Part-time job in public sector"'
3 `"Full-time job in private sector"'
4 `"Full-time job in public sector"'
5 `"Self-employed"'
6 `"Business owner, employs other people"'
7 `"Farmer works with the family"'
8 `"Farmer, employs other people"'
9 `"Fisherman"'
10 `"Religious work"'
11 `"Retired"'
12 `"Student"'
13 `"Housewife"'
14 `"Unemployed"'
15 "Local leader or elected official"
16 "Shepherd"
17 "Voluntary teacher"
;
#delimit cr

label variable S08_02 `"Name of board member"'

label values S08_03 female
label variable S08_03 `"Gender board member"'

label values S08_04 S08_04
label variable S08_04 `"Function of this board member"'

replace S08_04 = . if S08_04==8

replace S08_04 = 3 if S08_04_other=="Chefe de Turno"
replace S08_04 = 3 if S08_04_other=="Chefe de turno"
replace S08_04 = 3 if S08_04_other=="Coordenador da 6 classe"
replace S08_04 = 3 if S08_04_other=="Coordenador da Tarde"
replace S08_04 = 3 if S08_04_other=="Coordenador das actividades extraescolares"
replace S08_04 = 3 if S08_04_other=="Coordenador de Educação Fisica e desporto Escolar"
replace S08_04 = 3 if S08_04_other=="Coordenador de turno"
replace S08_04 = 3 if S08_04_other=="coordenador de turno da manhã"
replace S08_04 = 3 if S08_04_other=="coordenador de turno da tarde"
replace S08_04 = 3 if S08_04_other=="Coordenador do Modulo 3"
replace S08_04 = 3 if S08_04_other=="Coordenador ZIP"
replace S08_04 = 3 if S08_04_other=="Coordenadora"
replace S08_04 = 3 if S08_04_other=="Coordenadora de Turno"
replace S08_04 = 3 if S08_04_other=="Coordenadora Turna tarde"
replace S08_04 = 3 if S08_04_other=="Coordenadora Turno Manhã"
replace S08_04 = 3 if S08_04_other=="Representante do Simprof"
replace S08_04 = 3 if S08_04_other=="SiMprof"
replace S08_04 = 4 if S08_04_other=="Adjunto do chefe de Secretária"
replace S08_04 = 4 if S08_04_other=="Administrativa"
replace S08_04 = 4 if S08_04_other=="Administrativo"
replace S08_04 = 4 if S08_04_other=="Chefe do PAE"
replace S08_04 = 4 if S08_04_other=="Datilografo"
replace S08_04 = 4 if S08_04_other=="Membro do secretariado"
replace S08_04 = 4 if S08_04_other=="Responsável pelo livro de ponto na secretária"
replace S08_04 = 4 if S08_04_other=="subdirector administrativo"
replace S08_04 = 8 if S08_04_other=="Auxiliar de Limpeza"

drop ao8 S08_04_other

label variable S08_05 `"Position of this board member within school board"'
label values S08_05 S08_05
label variable S08_06 `"Years in school board"'
label variable S08_07 `"Age board member"'
label variable S08_08 `"Occupation board member"'
label variable S08_09 `"Highest level of education enjoyed by board member"'
label values S08_08 ocu
label values S08_09 edu2

foreach var in S08_06 S08_07 S08_08 S08_09{
	replace `var' = . if `var' == 999
	}

drop S08_08_other

rename (S08_02 S08_03 S08_04 S08_05 S08_06 S08_07 S08_08 S08_09) ///
		(S08_02_ S08_03_ S08_04_ S08_05_ S08_06_ S08_07_ S08_08_ S08_09_)

reshape wide S08_02_ S08_03_ S08_04_ S08_05_ S08_06_ S08_07_ S08_08_ ///
		S08_09_, i(ss_key) j(roster_id_S08_1)

forval x=1/9 {
	lab var S08_02_`x' "(`x') Name of board member"
	lab var S08_03_`x' "(`x') Gender board member"
	lab var S08_04_`x' "(`x') Function of this board member"
	lab var S08_05_`x' "(`x') Position of this board member within school board"
	lab var S08_06_`x' "(`x') Years in school board"
	lab var S08_07_`x' "(`x') Age board member"
	lab var S08_08_`x' "(`x') Occupation board member"
	lab var S08_09_`x' "(`x') Highest level of education enjoyed by board member"
	}

	save "$Endline_dtRaw/_intermediate files/school_S08_1.dta", replace

********************************************************************************

use "$Endline_dtRaw/_intermediate files/school.dta", clear

merge 1:1 ss_key using "$Endline_dtRaw/_intermediate files/school_S08_1.dta"

order 	S08_02_1 S08_03_1 S08_04_1 S08_05_1 S08_06_1 S08_07_1 S08_08_1 ///
		S08_09_1 S08_02_2 S08_03_2 S08_04_2 S08_05_2 S08_06_2 S08_07_2 ///
		S08_08_2 S08_09_2 S08_02_3 S08_03_3 S08_04_3 S08_05_3 S08_06_3 ///
		S08_07_3 S08_08_3 S08_09_3 S08_02_4 S08_03_4 S08_04_4 S08_05_4 ///
		S08_06_4 S08_07_4 S08_08_4 S08_09_4 S08_02_5 S08_03_5 S08_04_5 ///
		S08_05_5 S08_06_5 S08_07_5 S08_08_5 S08_09_5 S08_02_6 S08_03_6 ///
		S08_04_6 S08_05_6 S08_06_6 S08_07_6 S08_08_6 S08_09_6 S08_02_7 ///
		S08_03_7 S08_04_7 S08_05_7 S08_06_7 S08_07_7 S08_08_7 S08_09_7 ///
		S08_02_8 S08_03_8 S08_04_8 S08_05_8 S08_06_8 S08_07_8 S08_08_8 ///
		S08_09_8 S08_02_9 S08_03_9 S08_04_9 S08_05_9 S08_06_9 S08_07_9 ///
		S08_08_9 S08_09_9, after(S08_01)

drop _merge


********************************************************************************

label variable S08_10__1 `"School board contains a teacher representative"'
label variable S08_10__2 `"School board contains a parent representative"'
label variable S08_10__3 `"School board contains a community representative"'


drop S08_10__0

save "$Endline_dtRaw/_intermediate files/school.dta", replace

********************************************************************************

* Add roster

use "$Endline_dtRaw/school/S08_roster2.dta", clear

label drop _all

drop if inlist(interview__key,"69-28-11-74","12-88-13-89","67-33-56-05")

drop interview__id
rename interview__key 	ss_key
rename S08_roster2__id roster_id_S08_2


// labelssss

#delimit ;
;
label define dummy
0	"No"
1 	"Yes"
;
label define S08_roster2__id
1 `"Teacher representative"'
2 `"Parent representative"'
3 `"Community representative"'
;
label define S08_11
1 `"Directly appointed"'
2 `"Via elections"'
;
label define S08_12
1 `"Director"'
2 `"Director, confirmed by the school board"'
3 `"Director, confirmed by teachers"'
4 `"Director, confirmed by the parent committee"'
5 `"School board"'
6 `"Teachers"'
7 `"Parent committee"'
8 `"Provincial, municipal or comunal administration"'
;
label define S08_14
1 `"Every 6 months"'
2 `"Every year"'
3 `"Every two years"'
4 `"Every five years"'
5 `"When necessary"'
;
#delimit cr

label values roster_id_S08_2 roster_id_S08_2
label variable roster_id_S08_2 `"Roster instance identifier"'

label values S08_11 S08_11
label variable S08_11 `"Way of appointment for the school board"'
drop S08_11_other

label values S08_12 S08_12
label variable S08_12 `"Directly appointed for the school board by"'
drop S08_12_other

label variable S08_13__1 `"Director votes on appointment"'
label variable S08_13__2 `"School board votes on appointment"'
label variable S08_13__3 `"Teachers vote on appointment"'
label variable S08_13__4 `"Parent committtee vote on appointment"'
label variable S08_13__5 `"All parents vote on appointment"'
label variable S08_13__6 `"Other community members vote on appointment"'

drop S08_13__7 S08_13_other

label values S08_14 S08_14
label variable S08_14 `"Frequency elections for school board"'

replace S08_14 = . if S08_14==6

drop S08_14_other

********************************************************************************

rename (S08_11 S08_12 S08_13__1 S08_13__2 S08_13__3 S08_13__4 S08_13__5 ///
	S08_13__6 S08_14) (S08_11_ S08_12_ S08_13__1_ S08_13__2_ S08_13__3_ ///
	S08_13__4_ S08_13__5_ S08_13__6_ S08_14_)



reshape wide S08_11_ S08_12_ S08_13__1_ S08_13__2_ S08_13__3_ S08_13__4_ ///
	S08_13__5_ S08_13__6_ S08_14_, i(ss_key) j(roster_id_S08_2)

forval x=1/3 {
	lab var S08_11_`x' "(`x') Way of appointment for the school board"
	lab var S08_12_`x' "(`x') Directly appointed for the school board by"
	lab var S08_13__1_`x' "(`x') Director votes on appointment"
	lab var S08_13__2_`x' "(`x') School board votes on appointment"
	lab var S08_13__3_`x' "(`x') Teachers vote on appointment"
	lab var S08_13__4_`x' "(`x') Parent committtee vote on appointment"
	lab var S08_13__5_`x' "(`x') All parents vote on appointment"
	lab var S08_13__6_`x' "(`x') Other community members vote on appointment"
	lab var S08_14_`x' "(`x') Frequency elections for school board"
	}

	save "$Endline_dtRaw/_intermediate files/school_S08_2.dta", replace

	********************************************************************************

	use "$Endline_dtRaw/_intermediate files/school.dta", clear

	merge 1:1 ss_key using "$Endline_dtRaw/_intermediate files/school_S08_2.dta"

order 	S08_11_1 S08_12_1 S08_13__1_1 S08_13__2_1 S08_13__3_1 S08_13__4_1 	///
		S08_13__5_1 S08_13__6_1 S08_14_1 S08_11_2 S08_12_2 S08_13__1_2 		///
		S08_13__2_2 S08_13__3_2 S08_13__4_2 S08_13__5_2 S08_13__6_2 		///
		S08_14_2 S08_11_3 S08_12_3 S08_13__1_3 S08_13__2_3 S08_13__3_3 		///
		S08_13__4_3 S08_13__5_3 S08_13__6_3 S08_14_3, after(S08_10__3)

drop _merge

label values S08_15 dummy
label variable S08_15 `"Minutes school board"'

label variable S08_16 `"Number of school board meetings last year"'
replace S08_16 = . if S08_16==999

label values S08_17 dummy
label variable S08_17 `"School board approved plano of action"'

label variable S08_18__1 `"School board responsibilities: Decide how public funds are spend"'
label variable S08_18__2 `"School board responsibilities: Prepare development plan of school"'
label variable S08_18__3 `"School board responsibilities: Talk to parents about the absence of students"'
label variable S08_18__4 `"School board responsibilities: Talk to parents about the performance of students"'
label variable S08_18__5 `"School board responsibilities: Talk to teachers about their absence"'
label variable S08_18__6 `"School board responsibilities: Talk to teachers about their performance"'
label variable S08_18__7 `"School board responsibilities: Discuss the possibility to fire a teacher"'
label variable S08_18__8 `"School board responsibilities: Report school problems to superiors"'
label variable S08_18__9 `"School board responsibilities: Collect contributions from the community"'
label variable S08_18__10 `"School board responsibilities: Sugest changes in the teaching content"'
label variable S08_18__11 `"School board responsibilities: Sugest changes in the teaching methods"'
label variable S08_18__12 `"School board responsibilities: Discuss topics presented by parents"'
label variable S08_18__13 `"School board responsibilities: Discuss topics presented by teachers"'
label variable S08_18__14 `"School board responsibilities: Decide who should be in the parent committee"'
label variable S08_18__15 `"School board responsibilities: Maintenance of school infrastructures and facilities"'
label variable S08_18__16 `"School board responsibilities: Ensure safety at the school"'

lab val S08_18__1 S08_18__2 S08_18__3 S08_18__4 S08_18__5 S08_18__6 	///
		S08_18__7 S08_18__8 S08_18__9 S08_18__10 S08_18__11 S08_18__12 	///
		S08_18__13 S08_18__14 S08_18__15 S08_18__16 dummy

drop S08_18__17 S08_18__999

gen S08_18__17 = 0
gen S08_18__18 = 0
gen S08_18__19 = 0

label variable S08_18__17 `"School board responsibilities: General management"'
label variable S08_18__18 `"School board responsibilities: Quality control"'
label variable S08_18__19 `"School board responsibilities: Ceremonies"'

replace S08_18__4 = 1 if S08_18_other=="controlo dos alunos"
replace S08_18__6 = 1 if S08_18_other=="Acompanhamento das aulas dos professor"
replace S08_18__6 = 1 if S08_18_other=="Avaliar o desempenho dos professores"
replace S08_18__6 = 1 if S08_18_other=="Observação das aulas do professor"
replace S08_18__6 = 1 if S08_18_other=="Formação no quadro pessoal da escola"
replace S08_18__8 = 1 if S08_18_other=="Prestar conta a repartição Municipal da Educação"
replace S08_18__15 = 1 if S08_18_other=="Cuidar da higiene escolar"
replace S08_18__17 = 1 if S08_18_other=="Controle e gestão escolar"
replace S08_18__17 = 1 if S08_18_other=="Gestão da escola , controlo de toda actividade inerente da escola , Controlo de todo pessoal Docente"
replace S08_18__17 = 1 if S08_18_other=="planificação"
replace S08_18__17 = 1 if S08_18_other=="Pontual e assídua"
replace S08_18__17 = 1 if S08_18_other=="Supervisionar as actividades"
replace S08_18__17 = 1 if S08_18_other=="Velar o bom funcionamento da Escola"
replace S08_18__17 = 1 if S08_18_other=="Cuidar das transferência dos Aluno, distribuição das Merenda escolar aos aluno"
replace S08_18__17 = 1 if S08_18_other=="Prestar contas nas datas previstas"
replace S08_18__18 = 1 if S08_18_other=="Avalir o nível de organização da escola"
replace S08_18__18 = 1 if S08_18_other=="Controlo dos educando"
replace S08_18__18 = 1 if S08_18_other=="Coordenar todas actividades pedagogicas"
replace S08_18__18 = 1 if S08_18_other=="Dicidir o plano do lectivo; Cumprir e fazer cumprir as orientações superiores; Acompanhar o processo de ensino e aprendizagem"
replace S08_18__19 = 1 if S08_18_other=="Abertura do ano lectivo"

order S08_18__17 S08_18__18 S08_18__19, after(S08_18__16)

drop S08_18_other

********************************************************************************

********************************************************************************

* Section 9

// labelssss

#delimit ;
;
label define S09_01
1 `"Sim, em todas as classes"'
2 `"Sim, em algumas turmas (pelo menos uma)"'
0 `"N√£o"'
;
label define S09_03
1 `"Directly appointed"'
2 `"Via elections"'
;
label define S09_04
1 `"Director"'
2 `"School board"'
3 `"Previous parent committee"'
4 `"Local leader, coordinator neighborhood/community"'
5 "Other parents"
;
label define S09_06
1 `"Every year"'
2 `"Every two years"'
3 `"Every three years"'
4 `"Every five years"'
5 `"When necessary"'
;
label define S09_07
0 `"No, never"'
1 `"Yes, once per year"'
2 `"Yes, once per semester"'
3 `"Yes, once per trimester"'
4 `"Yes, once per month"'
5 `"Yes, but only when necessary"'
;
#delimit cr


label values S09_01 S09_01
label variable S09_01 `"Parent group/representation per class"'

label values S09_02 dummy
label variable S09_02 `"Parent committee"'

label values S09_03 S09_03
label variable S09_03 `"How selected for parent committee"'
drop S09_03_other

label values S09_04 S09_04
label variable S09_04 `"By who nominated for the parent committee"'
drop S09_04_other

label variable S09_05__1 `"Who can vote in elections for the parent committee:Direcctor da escola"'
label variable S09_05__2 `"Who can vote in elections for the parent committee:Dire√ß√£o da escola"'
label variable S09_05__3 `"Who can vote in elections for the parent committee:Professores"'
label variable S09_05__4 `"Who can vote in elections for the parent committee:Comiss√£o de pais/encarregados de educa√ß√£o de ano letivo anterior"'
label variable S09_05__5 `"Who can vote in elections for the parent committee:Todos os pais/encarregados de educa√ß√£o"'
label variable S09_05__6 `"Who can vote in elections for the parent committee:Cidad√£os da comunidade (que n√£o t√™m filhos nessa escola)"'
label variable S09_05__7 `"Who can vote in elections for the parent committee:Outro (especifique)"'

drop S09_05__999 S09_05_other

label values S09_06 S09_06
label variable S09_06 `"Frequency elections for parent committee"'

recode S09_06 (3=4) (4=5) (5=.) (999=.)
replace S09_06 = 5 if S09_06_other=="Por falta de participante so a eleição quando a vaga tiver sem ninguem"
replace S09_06 = 3 if S09_06_other=="De 3 em 3 anos"
replace S09_06 = 3 if S09_06_other=="De três em três anos"
replace S09_06 = 3 if S09_06_other=="Três em três anos"

drop S09_06_other

label values S09_07 S09_07
label variable S09_07 `"Frequency parent committee meetings"'
replace S09_07 = 2 if S09_07==6
drop S09_07_other

label values S09_08 dummy
label variable S09_08 `"Minutes of parent committee meetings"'

replace S09_08 = . if S09_08==999

label values S09_09 dummy
label variable S09_09 `"Parent committee has coordinator"'

replace S09_09 = . if S09_09==999

label variable S09_10 `"Size parent committee"'


********************************************************************************

save "$Endline_dtRaw/_intermediate files/school.dta", replace

********************************************************************************

* Add roster

use "$Endline_dtRaw/school/S09_roster.dta", clear

label drop _all

drop if inlist(interview__key,"69-28-11-74","12-88-13-89","67-33-56-05")

drop interview__id
rename interview__key 	ss_key
rename S09_roster__id roster_id_S09

// labelssss

#delimit ;
;
label define dummy
0	"No"
1 	"Yes"
;
label define female
0 `"Male"'
1 `"Female"'
;
label define edu2
0 `"No education"'
1 `"First grade"'
2 `"Primary school 1 (grades 1-4)"'
3 `"Primary school 2 (grades 5-6)"'
4 `"Secondary school 1 (grades 7-8) terceiro nivel"'
5 `"Secondary school 2 (grades 9-12) - ensino medio"'
6 `"Technical and Vocational Education (2-4 years)"'
7 `"University 1st year - Angola"'
8 `"University 1st year - abroad"'
9 `"University - Angola"'
10 `"University - abroad"'
11 `"Pos-graduation - Angola"'
12 `"Pos-graduation - abroad"'
;
label define ocu
1 `"Part-time job in private sector"'
2 `"Part-time job in public sector"'
3 `"Full-time job in private sector"'
4 `"Full-time job in public sector"'
5 `"Self-employed"'
6 `"Business owner, employs other people"'
7 `"Farmer works with the family"'
8 `"Farmer, employs other people"'
9 `"Fisherman"'
10 `"Religious work"'
11 `"Retired"'
12 `"Student"'
13 `"Housewife"'
14 `"Unemployed"'
15 "Local leader or elected official"
16 "Shepherd"
17 "Voluntary teacher"
;
#delimit cr

drop ao9 ao9cap

label variable S09_11 `"Name member parent committee"'

label values S09_12 female
label variable S09_12 `"Gender member parent committee"'

label variable S09_13 `"Time being member parent committee"'

label values S09_14 dummy
label variable S09_14 `"Member is coordinator"'

label variable S09_15 `"Year as coordinator of parent committee"'

label variable S09_16 `"Age member parent committee"'

label values S09_17 ocu
label variable S09_17 `"Occupation member parent committee"'

label values S09_18 edu2
label variable S09_18 `"Highest level of education enjoyed by member parent committee"'

foreach var in S09_13 S09_14 S09_15 S09_16 S09_17 S09_18{
	replace `var' = . if `var' == 999
	}

replace S09_17 = 5 if S09_17_other=="Alfaiate"
replace S09_17 = 5 if S09_17_other=="Carpintéiro"
replace S09_17 = 5 if S09_17_other=="Conta Própria"
replace S09_17 = 5 if S09_17_other=="Doméstica"
replace S09_17 = 5 if S09_17_other=="Mototaxista"

replace S09_17 = . if S09_17==15
replace S09_17 = 16 if S09_17_other=="Pastor"
replace S09_17 = 15 if S09_17_other=="Soba adjunto"
replace S09_17 = 15 if S09_17_other=="Soba do bairro"
replace S09_17 = 16 if S09_17_other=="criador de gado"

drop S09_17_other

********************************************************************************

rename 	(S09_11 S09_12 S09_13 S09_14 S09_15 S09_16 S09_17 S09_18) ///
		(S09_11_ S09_12_ S09_13_ S09_14_ S09_15_ S09_16_ S09_17_ S09_18_)

reshape wide S09_11_ S09_12_ S09_13_ S09_14_ S09_15_ S09_16_ S09_17_ S09_18_ ///
	, i(ss_key) j(roster_id_S09)

forval x=1/14 {
	lab var S09_11_`x' "(`x') Name member parent committee"
	lab var S09_12_`x' "(`x') Gender member parent committee"
	lab var S09_13_`x' "(`x') Time being member parent committee"
	lab var S09_14_`x' "(`x') Member is coordinator"
	lab var S09_15_`x' "(`x') Year as coordinator of parent committee"
	lab var S09_16_`x' "(`x') Age member parent committee"
	lab var S09_17_`x' "(`x') Occupation member parent committee"
	lab var S09_18_`x' "(`x') Highest level of education enjoyed by member"
	}

save "$Endline_dtRaw/_intermediate files/school_S09.dta", replace

********************************************************************************

use "$Endline_dtRaw/_intermediate files/school.dta", clear

merge 1:1 ss_key using "$Endline_dtRaw/_intermediate files/school_S09.dta"

order 	S09_11_1 S09_12_1 S09_13_1 S09_14_1 S09_15_1 S09_16_1 S09_17_1 	///
		S09_18_1 S09_11_2 S09_12_2 S09_13_2 S09_14_2 S09_15_2 S09_16_2 	///
		S09_17_2 S09_18_2 S09_11_3 S09_12_3 S09_13_3 S09_14_3 S09_15_3 	///
		S09_16_3 S09_17_3 S09_18_3 S09_11_4 S09_12_4 S09_13_4 S09_14_4 	///
		S09_15_4 S09_16_4 S09_17_4 S09_18_4 S09_11_5 S09_12_5 S09_13_5 	///
		S09_14_5 S09_15_5 S09_16_5 S09_17_5 S09_18_5 S09_11_6 S09_12_6 	///
		S09_13_6 S09_14_6 S09_15_6 S09_16_6 S09_17_6 S09_18_6 S09_11_7 	///
		S09_12_7 S09_13_7 S09_14_7 S09_15_7 S09_16_7 S09_17_7 S09_18_7 	///
		S09_11_8 S09_12_8 S09_13_8 S09_14_8 S09_15_8 S09_16_8 S09_17_8 	///
		S09_18_8 S09_11_9 S09_12_9 S09_13_9 S09_14_9 S09_15_9 S09_16_9 	///
		S09_17_9 S09_18_9 S09_11_10 S09_12_10 S09_13_10 S09_14_10 		///
		S09_15_10 S09_16_10 S09_17_10 S09_18_10 S09_11_11 S09_12_11 	///
		S09_13_11 S09_14_11 S09_15_11 S09_16_11 S09_17_11 S09_18_11 	///
		S09_11_12 S09_12_12 S09_13_12 S09_14_12 S09_15_12 S09_16_12 	///
		S09_17_12 S09_18_12 S09_11_13 S09_12_13 S09_13_13 S09_14_13 	///
		S09_15_13 S09_16_13 S09_17_13 S09_18_13 S09_11_14 S09_12_14 	///
		S09_13_14 S09_14_14 S09_15_14 S09_16_14 S09_17_14 S09_18_14, 	///
		after(S09_10)

drop _merge


********************************************************************************

* Section 10

// labelssss

#delimit ;
;
label define budget
1 `"Yes"'
2 `"No, only availble with a formal request"'
3 `"No, school does not have this available"'
;
label define S10_06
1 `"Once per month"'
2 `"Once per trimester"'
3 `"Once per semester"'
4 `"Once per year"'
5 `"Never"'
;
#delimit cr

label values S10_01 dummy
label variable S10_01 `"School has bank account"'

replace S10_01 = . if S10_01==999

label values S10_02 S10_03 budget
label variable S10_02 `"Budget 2018 available"'
label variable S10_03 `"Budget 2017 available"'

label values S10_04 dummy
label variable S10_04 `"Receipts 2017 available"'


label variable S10_05__1 `"Director is involved with school budget"'
label variable S10_05__2 `"Deputy director is involved with school budget"'
label variable S10_05__3 `"School board is involved with school budget"'
label variable S10_05__4 `"Teachers are involved with school budget"'
label variable S10_05__5 `"Parent committtee is involved with school budget"'
label variable S10_05__6 `"Provincial board is involved with school budget"'
label variable S10_05__7 `"Municipal/comunal administration is involved with school budget"'
label variable S10_05__8 `"Community is involved with school budget"'

label values S10_06 S10_06
label variable S10_06 `"Frequency review school budget"'

drop S10_05__9 S10_05_other S10_06_other


label variable S10_07 `"Total expenditures 2017"'
label variable S10_08 `"Total revenues 2017"'

replace S10_07 = . if S10_07==999
replace S10_08 = . if S10_08==999

replace S10_07 = S10_07/1000 if S10_07>5000000
replace S10_08 = S10_08/1000 if S10_08>5000000

********************************************************************************
********************************************************************************

save "$Endline_dtRaw/_intermediate files/school.dta", replace

********************************************************************************
********************************************************************************
